#include "QualificationRound_SIT.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
#include <map>

QualificationRound_SIT::QualificationRound_SIT(void)
{
	GooglereseToEnglishMapping['a'] = 'y';
	GooglereseToEnglishMapping['b'] = 'h';
	GooglereseToEnglishMapping['c'] = 'e';
	GooglereseToEnglishMapping['d'] = 's';
	GooglereseToEnglishMapping['e'] = 'o';
	GooglereseToEnglishMapping['f'] = 'c';
	GooglereseToEnglishMapping['g'] = 'v';
	GooglereseToEnglishMapping['h'] = 'x';
	GooglereseToEnglishMapping['i'] = 'd';
	GooglereseToEnglishMapping['j'] = 'u';
	GooglereseToEnglishMapping['k'] = 'i';
	GooglereseToEnglishMapping['l'] = 'g';
	GooglereseToEnglishMapping['m'] = 'l';
	GooglereseToEnglishMapping['n'] = 'b';
	GooglereseToEnglishMapping['o'] = 'k';
	GooglereseToEnglishMapping['p'] = 'r';
	GooglereseToEnglishMapping['q'] = 'z';
	GooglereseToEnglishMapping['r'] = 't';
	GooglereseToEnglishMapping['s'] = 'n';
	GooglereseToEnglishMapping['t'] = 'w';
	GooglereseToEnglishMapping['u'] = 'j';
	GooglereseToEnglishMapping['v'] = 'p';
	GooglereseToEnglishMapping['w'] = 'f';
	GooglereseToEnglishMapping['x'] = 'm';
	GooglereseToEnglishMapping['y'] = 'a';
	GooglereseToEnglishMapping['z'] = 'q';
}


QualificationRound_SIT::~QualificationRound_SIT(void)
{
	
}

void QualificationRound_SIT::SpeakingInTongues(const char* inputFile, const char* outputFile)
{
	string line;
	ifstream myfile(inputFile);
	ofstream output;
	output.open (outputFile);

	if(myfile.is_open())
	{
		
		getline(myfile, line);
		int numberOfInputs = atoi(line.c_str());
		for(int i=1; i<= numberOfInputs; i++)
		{
			getline(myfile, line);

			output << "Case #" << i << ": " <<  ProcessLine(line) << endl;
		}

		myfile.close();
	}	
	output.close();
}

string QualificationRound_SIT::ProcessLine(const string s)
{
	string result;
	
	for(unsigned int i=0; i<s.length(); i++)
	{
		if(s[i]==' ')
			result += ' ';
		else
			result += GooglereseToEnglishMapping[s[i]];
	}

	return result;
}
